<p>This rule raises an issue when <code>new Date()</code> is called with <code>date.getTime()</code> as an argument instead of passing the Date object
directly.</p>
<h2>Why is this an issue?</h2>
<p>The JavaScript <code>Date</code> constructor can accept another <code>Date</code> object directly as an argument to create a clone. When you pass
<code>date.getTime()</code> to <code>new Date()</code>, you are unnecessarily converting the date to a timestamp first, then back to a Date
object.</p>
<p>This approach has several drawbacks:</p>
<ul>
  <li> <strong>Reduced readability</strong>: The code is more verbose and less clear about the intent to clone a date </li>
  <li> <strong>Unnecessary computation</strong>: Converting to timestamp and back involves extra processing steps </li>
  <li> <strong>Less idiomatic</strong>: Modern JavaScript (ES2015+) supports direct date cloning, making this the preferred approach </li>
</ul>
<p>The direct approach <code>new Date(date)</code> is cleaner, more efficient, and clearly expresses the intent to create a copy of an existing
date.</p>
<h3>What is the potential impact?</h3>
<p>This issue primarily affects code readability and maintainability. While the performance impact is minimal, using the direct cloning approach makes
the code more idiomatic and easier to understand for other developers.</p>
<h3>How to fix?</h3>
<p>Pass the Date object directly to the Date constructor instead of calling getTime() first.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const originalDate = new Date();
const clonedDate = new Date(originalDate.getTime()); // Noncompliant
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const originalDate = new Date();
const clonedDate = new Date(originalDate);
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/consistent-date-clone.md">consistent-date-clone</a> </li>
  <li> MDN - Date constructor - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date">Official
  documentation for the Date constructor, including examples of cloning dates</a> </li>
  <li> MDN - Date.prototype.getTime() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime">Documentation for the getTime() method and when
  to use it</a> </li>
</ul>
